package br.ufrj.dcc.manifestacoes.dataMining;

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import br.ufrj.dcc.manifestacoes.util.Constantes;
import br.ufrj.dcc.manifestacoes.util.TextMiningUtil;

public class Cleaning {

	public static String clean(ArrayList<String> stopWords, String comentario){
		
		String regex = TextMiningUtil.getRegex(stopWords);
        Pattern p = Pattern.compile(regex + "|" + Constantes.SPECIAL_CHARACTERS_REGEX,Pattern.CASE_INSENSITIVE);
        comentario = comentario.toLowerCase();
        Matcher m = p.matcher(comentario);
        String cleanMessage = comentario;
        while(m.find()){
        	cleanMessage = m.replaceAll(" ");
        	m = p.matcher(cleanMessage);
        }
        return cleanMessage; 
	}

}
